﻿<?php
include("../conn.php");
if(isset($_GET['submit']))
{
	$addsql="insert into daohang(name,url) values ('".$_GET['dhname']."','".$_GET['dhurl']."')";
	mysqli_query($con,$addsql);
}
if($_GET['dhid']&&$_GET['del']=="yes")
{
	$delsql="delete from daohang where id='".$_GET['dhid']."'";
	mysqli_query($con,$delsql);
	echo "删除成功!<a href=editdh.php>返回</a>";exit;
}
if(isset($_POST['submit']))
{
	$upsql="update daohang set name='".$_POST['ddhname']."' , url='".$_POST['ddhurl']."' where id='".$_GET['dhid']."'";
	mysqli_query($con,$upsql);
	echo "修改成功!<a href=editdh.php>返回</a>";
	exit;
}
if($_GET['dhid'])
{
	$sesql="select * from daohang";
	$sequery=mysqli_query($con,$sesql);
	$serow=mysqli_fetch_array($sequery,MYSQLI_ASSOC);
	?>
	<form action="" method=POST>
		导航名称:<input type=text name=ddhname value=<?php echo $serow['name']?> ><br />
		链接地址:<input type=text name=ddhurl value=<?php echo $serow['url']?> ><br />
		<input type=submit name=submit value=修改>
	</form>
	<?php
	exit;
}
$sql="select * from daohang";
$query=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($query,MYSQLI_ASSOC))
{
echo "<a href=?dhid=".$row['id'].">".$row['name']."</a> <a href=?dhid=".$row['id']."&&del=yes >删</a>　";
}
?>
<form action="" name=myform method=GET>
	导航名称:<input type=text name=dhname><br />
	链接地址:<input type=text name=dhurl value=><br />
	<input type=submit name=submit value=添加>
</form>